<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加用户</title>
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
function mySubmit(){
	$.post(
		"/userServlet?operate=add&abcd="+new Date().getTime(),
		{
			username:$("#username").val(),
			truename:$("#truename").val(),
			password:$("#password").val(),
			email:$("#email").val()
		},
		function(data){
			var s = "<span id=\"msg\">"+data+"</span>";
			$("#ppp").html(s);
			$("#msg").css("color","red");
			$("#msg").fadeOut(1000);
		},
		"text");
	
}

function mySubmit2(){
	var s="";
	var username=$("#username").val();
	var truename=$("#truename").val();
	var password=$("#password").val();
	var email=$("#email").val();
	s="<tr><td>"+username+"</td><td>"+truename+"</td><td>"+password+"</td><td>"+email+"</td></tr>";
	$("#mytable").append(s);
}

function mySubmit3(){
	var str="";
	$("#mytable tr").each(function(){
		var s="";
		var tds = $(this).find("td");
		$.each(tds,function(i,data){
			s+=$(data).text()+",";
		});
		str+=s+";";
	});
	$.post(
			"/userServlet?operate=add&abcd="+new Date().getTime(),
			{param:str},
			function(data){
				var s = "<span id=\"msg\">"+data+"</span>";
				$("#ppp").html(s);
				$("#msg").css("color","red");
				$("#msg").fadeOut(1000);
			},
			"text");
}
</script>
</head>
<body>
<center>

<form action="/userServlet" method="post">
用户名:<input id="username" name="username" type="text"/><br/>
真实名:<input id="truename" name="truename" type="text"/><br/>
密      码:<input id="password" name="password" type="password"/><br/>
email:<input id="email" name="email" type="text"/><br/>
<input type="button"  onclick="mySubmit2()"  value="添加"/> <input type="reset" value="取消"/>
</form>
<br/>
<br/>
<p id="ppp"></p>

<table id="mytable" name="mytable" border="1"></table>

<input type="button"  onclick="mySubmit3()"  value="提交"/>


</center>
</body>
</html>